/**
 * 2013-6-3 上午6:48:08 Created By niexiaoqiang
 */

package com.xiaoqiang.network;

import java.io.IOException;

import com.xiaoqiang.network.event.ServerMsgEvent;
import com.xiaoqiang.util.Logger;

/**
 * 服务器消息接受线程
 */
public class ServerMessageReviceThread implements Runnable {

	MySocketClient mySocketClient;
	private static Logger log = new Logger(ServerMessageReviceThread.class);

	public ServerMessageReviceThread(MySocketClient mySocketClient) {
		this.mySocketClient = mySocketClient;

	}

	@Override
	public void run() {
		while (!mySocketClient.isclose) {
			try {
				String msg = mySocketClient.sin.readLine();
				log.debug("reveice client message:" + msg);
				mySocketClient.notifyListeners(new ServerMsgEvent(msg));
			}
			catch (IOException e) {
				log.error(e);
			}
		}
	}
}
